//
// Created by tang on 2022/10/24.
//

#ifndef LEARNOPENGL_VERTEX_ARRARY_HPP
#define LEARNOPENGL_VERTEX_ARRARY_HPP

#include "gl/gl_validation.hpp"
#include "gl/buffer.hpp"

namespace GL {

    UNIQUE_HANDLE(VertexArray);

    class VertexArray final {
        static constexpr GLuint MAX_BUFFER_CNT = 16;
    public:
        explicit VertexArray(GLuint buffer_cnt);
        ~VertexArray();

        void Bind() const;
        void UnBind() ;

        [[nodiscard]] BufferPtr Get(GLuint index) const;

        BufferPtr operator[](GLuint index) const;

        FACTORY_METHOD(VertexArray, GLuint buffer_cnt = 1);

    private:
        GLuint m_handle_;
        GLuint const m_buffer_cnt_;
        BufferPtr m_buffers_[MAX_BUFFER_CNT];
    };
}

#endif//LEARNOPENGL_VERTEX_ARRARY_HPP
